package com.sidom.movieIndexer.domain.google;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

import com.sidom.movieIndexer.domain.Movie;

/**
 * A class representing of a GoogleSearchResult.
 * 
 * @author Siebe
 */
public class GoogleSearchResult {
	/**
	 * The imdbUrl found in the {@link Response} from Google.
	 */
	private String imdbUrl;
	/**
	 * The match type of the {@link Movie} see {@link Match}.
	 */
	private Match match;
	/**
	 * {@link Response} from Google.
	 */
	private Response response;
	
	/**
	 * Constructor of {@link GoogleSearchResult}.
	 * @param response The {@link Response} from Google.
	 */
	public GoogleSearchResult(Response response) {
		super();
		this.response = response;
	}
	
	/**
	 * @return the imdbUrl
	 */
	public final String getImdbUrl() {
		return imdbUrl;
	}
	/**
	 * @param imdbUrl the imdbUrl to set
	 */
	public final void setImdbUrl(final String imdbUrl) {
		this.imdbUrl = imdbUrl;
	}
	
	/**
	 * @return the match
	 */
	public final Match getMatch() {
		return match;
	}
	/**
	 * @param match the match to set
	 */
	public final void setMatch(final Match match) {
		this.match = match;
	}
	
	/**
	 * @return the response
	 */
	public Response getResponse() {
		return response;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public final int hashCode() {
		return new HashCodeBuilder()
								.append(imdbUrl)
								.append(match)
								.hashCode();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public final boolean equals(final Object obj) {
		if(obj==this){
			return true;
		}
		if(!(obj instanceof GoogleSearchResult)){
			return false;
		}
		GoogleSearchResult googleSearchResultToCheck = (GoogleSearchResult)obj;
		return new EqualsBuilder()
							.append(imdbUrl, googleSearchResultToCheck.getImdbUrl())
							.append(match, googleSearchResultToCheck.getMatch())
							.isEquals();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public final String toString() {
		return ReflectionToStringBuilder.toString(this);
	}
}
